﻿/**
 * ...
 * @author Артём Григорьев
 */

package gui.hug;
import flash.display.Sprite;
import gui.hug.HUGSprite;
import gui.hug.priv.HUGTabButton;
import loader.Loader;
import client.Channel;
import list.NewList;

class Tab 
{

	private var button : HUGTabButton;
	private var name : String;
	private var content : HUGSprite;
	private var closable : Bool;
	private var panel : HUGTabbedPanel;
	private var type: Int;
	private var load :Loader;
	private var newsList1 : NewList;
	
	private var loadingLabel : HUGLabel;
	
	// useful identificator
	// if ids are equal HUGTabbedPanel thinks that tabs are equal
	private var id : UInt;
	
	/**
	 * 
	 * @param	content			sprite with tab's content
	 * @param	name			string on tab button
	 * @param	panel = null	reference to panel which contains this tab
	 * @param	closable = true	may be closed?
	 */
	public function new(content : HUGSprite, name : String = "Tab",type:Int, panel = null, closable = true ) 
	{
		this.name = name;
		this.content = content;
		this.panel = panel;
		this.button = new HUGTabButton(name, false);
		this.closable = closable;
		this.type = type;
		
		// Loading label
		this.loadingLabel = new HUGLabel();
		this.loadingLabel.text = "Загрузка...";
		this.loadingLabel.visible = false;
		var width = this.loadingLabel.getBounds(this.panel).width;
		this.loadingLabel.x = (607 - width) / 2;
		this.loadingLabel.y = 230;
		
		newsList1 = new NewList(4, 40, 600);
		this.content.addChild(this.loadingLabel);
	}
	
	public function getButton() { return button; }
	public function getName() { return name; }
	
	public function getContent() { 
		

		return content;
		
		}
		


		
	//public function getNewContent() {  ; }
	public function getPanel() { return panel; }
	public function getType() { return type; }
	
	public function setButton(value : HUGTabButton) { this.button = value; }
	public function setName(value : String) { this.name = value; }
	public function setContent(value : HUGSprite) { this.content = value; }
	public function setId(id : UInt) { this.id = id; }
	public function setType(type : Int) { this.type = type; }
	
	public function isClosable() { return closable; }
	
	public function showLoading(show : Bool) {
		this.loadingLabel.visible = show;
	}
	
	public function equals(other : Tab) 
	{
		return other.id == id;
	}
}